package com.tl.bootmeter.mapper;

import com.tl.bootmeter.pojo.WellMode;
import com.tl.bootmeter.pojo.WellStation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WellModeMapper {
    //根据站的id查询这个站下面有多少个井的信息
    @Select("select s.station_id,s.station_name,wd.well_id,wd.well_namber,wd.well_type \n" +
            "\t\tfrom station s RIGHT JOIN well_station ws ON s.station_id = ws.station_id RIGHT JOIN well_mode wd on ws.well_id = wd.well_id\n" +
            "\t\twhere s.station_id = #{station_id}")
    List<WellMode> selectBystationIdWellMode(int station_id);

    //根据站id查询站名称
    @Select("select station_name from station where station_id = #{station_id}")
    String selectStationNameBystationId(int station_id);

    //新增井
    @Insert("INSERT INTO WELL_MODE VALUES(#{well_id},#{well_namber},#{well_type})")
    int insertByWellMode(WellMode wellMode);
    //新增井的时候同时向井与站的中间表中添加数据
    @Insert("INSERT INTO WELL_STATION VALUES(#{well_id},#{station_id})")
    int insertWellStationByStationId(WellStation wellSation);
}
